1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![allow(non_camel_case_types, non_snake_case)]

use crate::co;
use crate::decl::*;
use crate::kernel::ffi_types::*;
use crate::ole::privs::*;
use crate::prelude::*;
use crate::vt::*;

/// [`IMFAsyncCallback`](crate::IMFAsyncCallback) virtual table.
#[repr(C)]
pub struct IMFAsyncCallbackVT {
	pub IUnknownVT: IUnknownVT,
	pub GetParameters: fn(COMPTR, *mut u32, *mut u32) -> HRES,
	pub Invoke: fn(COMPTR, COMPTR) -> HRES,
}

com_interface! { IMFAsyncCallback: "a27003cf-2354-4f2a-8d6a-ab7cff15437e";
	/// [`IMFAsyncCallback`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nn-mfobjects-imfasynccallback)
	/// COM interface over
	/// [`IMFAsyncCallbackVT`](crate::vt::IMFAsyncCallbackVT).
	///
	/// Automatically calls
	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
	/// when the object goes out of scope.
}

impl mf_IMFAsyncCallback for IMFAsyncCallback {}

/// This trait is enabled with the `mf` feature, and provides methods for
/// [`IMFAsyncCallback`](crate::IMFAsyncCallback).
///
/// Prefer importing this trait through the prelude:
///
/// ```no_run
/// use winsafe::prelude::*;
/// ```
pub trait mf_IMFAsyncCallback: ole_IUnknown {
	/// [`IMFAsyncCallback::GetParameters`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasynccallback-getparameters)
	/// method.
	///
	/// Returns the flag and the ID of the work queue.
	#[must_use]
	fn GetParameters(&self) -> HrResult<(co::MFASYNC, u32)> {
		let (mut flags, mut queue) = (co::MFASYNC::default(), u32::default());
		ok_to_hrresult(
			unsafe {
				(vt::<IMFAsyncCallbackVT>(self).GetParameters)(
					self.ptr(),
					flags.as_mut(),
					&mut queue,
				)
			},
		).map(|_| (flags, queue))
	}

	/// [`IMFAsyncCallback::Invoke`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasynccallback-invoke)
	/// method.
	fn Invoke(&self, async_result: &impl mf_IMFAsyncResult) -> HrResult<()> {
		ok_to_hrresult(
			unsafe {
				(vt::<IMFAsyncCallbackVT>(self).Invoke)(
					self.ptr(),
					async_result.ptr(),
				)
			},
		)
	}
}